<!DOCTYPE html>
<html>
  <body>

  <script type="text/javascript">
    console.log(global); // undefined
    var global = 'global';
    console.log(global); // global

    function fn () {
    　　console.log(a); // undefined
    　　var a = 'aaa';
    　　console.log(a); // aaa
    }
    fn();

    var foo = 1;
    function bar(){
      if(!foo){
        var foo = 10;
      }
      console.log(foo); //=>10
    }
    bar()
  </script>

</body>
</html>
